//
//  DeviceItem.m
//  SqliteManagerDemo
//
//  Created by US bike on 2017/9/14.
//  Copyright © 2017年 US bike. All rights reserved.
//

#import "DeviceItem.h"

@implementation DeviceItem

- (instancetype) initWithStr:(NSString *) str {
    
    self = [super init];
    
    if (self) {
        
        NSArray<NSString *> *array = [str componentsSeparatedByString:@","];
        
        if (array.count != 5) {
            NSLog(@"数据不正确");
        } else {
            self.recordID = array[0];
            self.deviceID = array[1];
            self.recordState = [array[2] integerValue];
            self.address = array[3];
            self.update = array[4];
        }
    }
    
    return self;
}



- (NSString *) dataStr {
    
    return [NSString stringWithFormat:@"%@,%@,%@,%@,%@",self.recordID, self.deviceID, [@(self.recordState) stringValue] , self.address, self.update];
}


@end
